import { RouteRecordRaw } from "vue-router";
import NoAuthView from "@/views/NoAuthView.vue";
import ACCESS_ENUM from "@/access/accessEnum";
import UserLayout from "@/layouts/UserLayout.vue";
import UserLoginView from "@/views/user/UserLoginView.vue";
import UserRegisterView from "@/views/user/UserRegisterView.vue";
import AddQuestionView from "@/views/question/AddQuestionView.vue";
import ManageQuestionView from "@/views/question/ManageQuestionView.vue";
import QuestionView from "@/views/question/QuestionView.vue";

import DoQuestionOnlineView from "@/views/question/DoQuestionOnlineView.vue";

import HomeView from "@/views/Home/HomeView.vue";
import CommunityView from "@/views/community/communityView.vue";
import PostView from "@/views/community/postView.vue";
import PersonalHomeView from "@/views/personalHome/PersonalHomeView.vue";
import UpdateQuestionView from "@/views/question/updateQuestionView.vue";
import SignInView from "@/views/community/SignInView.vue";
import CorrectionView from "@/views/question/CorrectionView.vue";

export const routes: Array<RouteRecordRaw> = [
  {
    path: "/user",
    name: "用户",
    component: UserLayout,
    children: [
      {
        path: "/user/login",
        name: "用户登录",
        component: UserLoginView,
      },
      {
        path: "/user/register",
        name: "用户注册",
        component: UserRegisterView,
      },
    ],
    meta: {
      hideInMenu: true,
    },
  },
  {
    path: "/",
    name: "主页",
    component: HomeView,
  },

  {
    path: "/question",
    name: "浏览题目",
    component: QuestionView,
  },
  {
    path: "/view/question/:id",
    name: "在线做题",
    component: DoQuestionOnlineView,
    props: true,
    meta: {
      access: ACCESS_ENUM.USER,
      hideInMenu: true,
    },
  },
  {
    path: "/add/question",
    name: "创建题目",
    component: AddQuestionView,
    meta: {
      access: ACCESS_ENUM.USER,
    },
  },
  {
    path: "/update/question",
    name: "更新题目",
    component: UpdateQuestionView,
    meta: {
      access: ACCESS_ENUM.USER,
      hideInMenu: true,
    },
  },
  {
    path: "/manage/question",
    name: "管理题目",
    component: ManageQuestionView,
    meta: {
      access: ACCESS_ENUM.ADMIN,
    },
  },
  {
    path: "/community",
    name: "社区",
    component: CommunityView,
    meta: {
      access: ACCESS_ENUM.USER,
    },
  },
  {
    path: "/add/post",
    name: "添加帖子",
    component: PostView,
    meta: {
      access: ACCESS_ENUM.USER,
      hideInMenu: true,
    },
  },
  {
    path: "/signIn",
    name: "签到",
    component: SignInView,
    meta: {
      access: ACCESS_ENUM.USER,
      hideInMenu: true,
    },
  },
  {
    path: "/correction",
    name: "错题本",
    component: CorrectionView,
    meta: {
      access: ACCESS_ENUM.USER,
    },
  },
  {
    path: "/personalHome",
    name: "个人主页",
    component: PersonalHomeView,
    meta: {
      access: ACCESS_ENUM.USER,
    },
  },
  {
    path: "/noAuth",
    name: "无权限",
    component: NoAuthView,
    meta: {
      hideInMenu: true,
    },
  },
];
